﻿<link href="@SiteUrl.GetStaticResourceScriptUrl("~/Content/css/TemperatureChart.css", false)" rel="stylesheet" />
<style type="text/css">
    #tablBaseInfo {
        margin: 5px 0 0 3px;
    }

        #tablBaseInfo td {
            padding: 3px 5px;
        }
</style>
<table id="tablBaseInfo" class="form" style="width:750px;">
    <tr>
        <td class="formValue" colspan="4">日期：<label id="lblRq"></label></td>
    </tr>
    <tr>
        <td class="formValue">姓名：<label id="lblXm"></label></td>
        <td class="formValue">病历号：<label id="lblBlh"></label></td>
        <td class="formValue">住院号：<label id="lblZyh"></label></td>
        <td class="formValue">病区：<label id="lblBq"></label></td>
    </tr>
    <tr>
        <td class="formValue">床位：<label id="lblCw"></label></td>
        <td class="formValue">入院日期：<label id="lblRqrq"></label></td>
        <td class="formValue" style="display:none">出区日期：<label id="lblCqrq"></label></td>
    </tr>
</table>
<div id="3cbill">
    <div class="drawingboard" id="board0">
        <table class="bottomtbl">
            <tr>
                <td>呼吸(次/分)</td>
            </tr>
            <tr>
                <td>血压(mmHg)</td>
            </tr>
            <tr>
                <td>血氧饱和度%</td>
            </tr>
            <tr>
                <td>氧流量(升/分)</td>
            </tr>
            <tr>
                <td>大便次数</td>
            </tr>
            <tr>
                <td>摄入量(ml)</td>
            </tr>
            <tr>
                <td>小&nbsp;&nbsp;便(ml)</td>
            </tr>
            <tr>
                <td>呕吐量(ml)</td>
            </tr>
            <tr>
                <td>引流量(ml)</td>
            </tr>
            <tr>
                <td>输入液体量(ml)</td>
            </tr>
            <tr>
                <td>体&nbsp;&nbsp;重(kg)</td>
            </tr>
            <tr>
                <td>身&nbsp;&nbsp;高(cm)</td>
            </tr>
        </table>
    </div>
</div>
<script>
    var billIndex = 0;//三测单分页标记
    var $board = null
    //base
    var spc = 16;
    var sspace = 11;
    var sspacewidth = 14;
    var outerspace = 3; //体温单外部留白
    var xouterspace = 3;
    var bodyHeight = 700;   //整体的高度
    var origin;
    //calc
    var sjStartTop;
    var contentStartTop;
    var contentStartLeft;

    //血压、脉搏、呼吸、体温
    var twArr = [42, 41, 40, 39, 38, 37, 36, 35, 34];
    var hxArr = [80, 70, 60, 50, 40, 30, 20, 10, 0];
    var mbArr = [180, 160, 140, 120, 100, 80, 60, 40, 20];
    var xyArr = [180, 160, 140, 120, 100, 80, 60, 40, 20];
    var wljwArr = [42, 41, 40, 39, 38, 37, 36, 35, 34];

    var twColor = 'cblack';
    var hxColor = 'cblue';
    var mbColor = 'cred';
    var xyszColor = 'corange';
    var xyxzColor = 'corange';
    var wljwColor = 'cred';

    //体温单content下边框的top坐标
    var twLastTop;
    //体温单content右边框的left坐标
    var twLastLeft;

    var bottomtrCount = $('.bottomtbl tr').length;
    var bodyLastTop;

    var rqCellValueArr = new Array();

    var ryrq;
    //定位
    if (window.top == window.self) {
        $('#tablBaseInfo').css('marginLeft', 30);
    }

    function reLocation() {
        origin = { x: xouterspace, y: 0 + outerspace };
        //calc
        sjStartTop = origin.y + spc * 2;
        contentStartTop = origin.y + spc * 3;
        contentStartLeft = origin.x + sspacewidth * 6;   //6格  //但得多给点宽度

        //体温单content下边框的top坐标
        twLastTop = contentStartTop + sspace * 5 * (twArr.length - 1);

        bodyLastTop = twLastTop + spc * bottomtrCount;
    };

    function search(kssj, jssj, zyh) {
        tempData = null; //
        tempKssj = null;
        $('#tablBaseInfo td label').html('');
        if (!kssj || !jssj || !zyh) {
            $.modalAlert('请完善筛选条件', 'error');
            return;
        }
        billIndex = 0;
        $("#3cbill").empty();//清空三测单内容
        $.najax({
            url: "/NurseManage/InpatientVitalSigns/GetTemperatureChartJson",
            data: { kssj: kssj, jssj: jssj, zyh: zyh },
            loadingtext: "体温单数据请求中，请稍后...",
            asnyc: false,
            success: function (data) {
                //
                if (!(data && data.list && data.list.length)) {
                    //draw([]);
                    if (!(data && data.patInfo)) {
                        $.modalAlert('请选择住院号', 'warning');
                        return;
                    }
                    //return;
                }
                //填充基本信息表格
                if (data && data.patInfo) {
                    fillPatBaseInfo(data.patInfo);
                    ryrq = data.patInfo.ryrq;
                }
                $('#lblRq').html($.getDate({ date: kssj }) + " 至 " + $.getDate({ date: jssj }));
                //
                if (!(data && data.list && data.list.length)) {
                    data.list = [];
                }

                //tempKssj = kssj = $.getDate({ date: kssj });   //容错一下
                //不显示入院日期前的日期表格
                tempKssj = kssj = ryrq > kssj ? ryrq : $.getDate({ date: kssj });   //容错一下

                var printHasNext = true;
                while (printHasNext) {
                    // 当前开始时间
                    var thiskssj = tempKssj;
                    // 当前结束时间
                    var thisjssj = $.getDate({ date: $.dateAdd($.strToDate(thiskssj), 'd', 6) });
                    var billHtml = '<div class="drawingboard" id="board' + billIndex + '" style="width:1139px;height:660px;"><table class="bottomtbl"><tr><td>呼吸(次/分)</td></tr>';
                    billHtml += '<tr><td>血压(mmHg)</td></tr><tr><td>血氧饱和度%</td></tr><tr><td>氧流量(升/分)</td></tr>';
                    billHtml += '<tr><td>大便次数</td></tr><tr><td>摄入量(ml)</td></tr><tr><td>小&nbsp;&nbsp;便(ml)</td></tr>';
                    billHtml += '<tr><td>呕吐量(ml)</td></tr><tr><td>引流量(ml)</td></tr><tr><td>输入液体量(ml)</td></tr><tr><td>体&nbsp;&nbsp;重(kg)</td></tr>';
                    billHtml += '<tr><td>身&nbsp;&nbsp;高(cm)</td></tr></table></div>';
                    $(billHtml).appendTo($("#3cbill"))
                    rqCellValueArr.splice(0, rqCellValueArr.length);
                    for (var sj = thiskssj; sj <= thisjssj;) {
                        rqCellValueArr.push(sj);
                        var dateSj = $.strToDate(sj);
                        dateSj.add('d', 1);
                        sj = $.getDate({ date: dateSj });
                    }

                    var drawData = [];
                    for (var i = 0; i < data.list.length; i++) {
                        var item = data.list[i];
                        if ($.getDate({ date: item.rq }) >= thiskssj && $.getDate({ date: item.rq }) <= thisjssj) {
                            drawData.push(item);
                        }
                    }

                    draw(drawData, billIndex);
                    if (thisjssj >= jssj) {
                        printHasNext = false;
                    }
                    //重置下个开始时间
                    if (printHasNext) {
                        tempKssj = $.getDate({ date: $.dateAdd($.strToDate(thisjssj), 'd', 1) });
                        billIndex++;
                    }
                }
            }
        });
    }

    var tempData;    //使用setTimeout需要
    var tempKssj;
    function draw(data, index) {
        //先重置
        $board = $('#board' + index);
        $board.find('>*:not(table)').remove();
        $.each($('#board' + index + ' .bottomtbl tr'), function () {
            $(this).find('td:gt(0)').remove();
        });
        if (!rqCellValueArr || !rqCellValueArr.length) {
            //return;
        }
        //样式
        var docwd = $(document).width();
        var twdContentWidth = sspacewidth * 6 * (rqCellValueArr.length);
        twdContentWidth += sspacewidth * 9; //做日期列
        if ((docwd - twdContentWidth).toFixed(2) > 50) {
            if (window.top != window.self) {
                if (!rqCellValueArr || !rqCellValueArr.length) {

                }
                else {
                    xouterspace = parseInt((docwd - twdContentWidth).toFixed(2) / 2);  //可以多留点白
                }
            }
            else {
                xouterspace = 30;
            }
        }
        else {
            xouterspace = 3;    //default
        }
        //
        reLocation();
        twLastLeft = contentStartLeft + sspacewidth * 6 * (rqCellValueArr.length);
        //
        if (!(window.isIE() && window.isIElte8())) {
            //添加画布canvas
            $('#board' + index).append('<canvas id="drawCanvas' + index + '" width="' + twLastLeft + '" height="' + (twLastTop + 10) + '"></canvas> ');
            checkCanvasAble();
        }
        //画
        tempData = data;
        if (canvasAble) {
            startDraw();
        }
        else {
            setTimeout("$.loading(true, '体温单绘制中，请稍后...');", 25);
            setTimeout("startDraw();", 50);
        }
    }

    function startDraw() {
        var data = tempData;
        //
        drawTemplet(data);
        //
        if (canvasAble) {
            startDraw2();
        }
        else {
            setTimeout("startDraw2();", 50);
        }
    }

    function startDraw2() {
        var data = tempData;
        //
        drawDataPoint(data);
        //
        if (canvasAble) {
            startDraw3();
        }
        else {
            $.loading(true, '连线绘制中，可能耗时较长，请稍后...');
            setTimeout("startDraw3();", 50);
        }
    }

    function startDraw3() {
        var data = tempData;
        //
        drawDataLigature(data);
        //
        if (canvasAble) {
        }
        else {
            $.loading(false);
        }
    }

    //根据data重置画板 长高
    function drawTemplet(data) {
        //画板的长宽
        var totalwidth = $(window).width();
        var totalheight = bodyHeight;
        $board.css('width', totalwidth);
        $board.css('height', totalheight);
        //时间点上边框
        drawLine(origin.x, origin.y, twLastLeft - origin.x);
        //右侧加一点空白
        drawLine(twLastLeft, origin.y, xouterspace).css('visibility', 'hidden');
        //body上边框
        drawLine(origin.x, sjStartTop, twLastLeft - origin.x);
        //body上边框
        drawLine(origin.x, sjStartTop - spc, twLastLeft - origin.x);
        //body左边框
        drawLine(origin.x, origin.y, bodyLastTop - origin.y, '', 'vline');
        //content左边框
        drawLine(contentStartLeft, origin.y, bodyLastTop - origin.y, '', 'vline');
        //content上边框
        drawLine(origin.x, contentStartTop, twLastLeft - origin.x);

        //竖向画线
        var rqCellCount = rqCellValueArr.length;
        for (var i = 0; i < rqCellCount; i++) {
            //右线
            var left = contentStartLeft + sspacewidth * 6 * (i + 1);
            if (i == rqCellCount - 1) {
                //最右侧画黑线
                drawLine(left, origin.y, twLastTop - origin.y, '', 'vline');
            } else {
                drawLine(left, origin.y, twLastTop - origin.y, 'cred', 'vline');
            }
            //底部table画竖线
            drawLine(left, twLastTop, bodyLastTop - twLastTop, '', 'vline');
            //中间5条时间点的线
            for (var j = 0; j < 5; j++) {
                left = contentStartLeft + sspacewidth * 6 * i + sspacewidth * (j + 1);
                if (j === 2) {
                    //drawLine(left, sjStartTop, twLastTop - sjStartTop + spc * 11, '', 'vline');
					drawLine(left, sjStartTop, twLastTop - sjStartTop + spc * 1, '', 'vline');
                }
                else {
                    drawLine(left, sjStartTop, twLastTop - sjStartTop + spc, '', 'vline');
                }
            }
        }
        //横向画线
        for (var i = 0; i < (twArr.length - 1); i++) {
            var top = contentStartTop + sspace * 5 * (i + 1);
            //最后一条左起origin
            var left = i == (twArr.length - 1 - 1) ? origin.x : contentStartLeft;
            //最后一条颜色默认
            var colr = i == (twArr.length - 1 - 1) ? '' : 'c666';
            //最后一条不加粗
            var bold = i == (twArr.length - 1 - 1) ? '' : 'bold';
            drawLine(left, top, twLastLeft - left, colr, '', bold);
            //左侧血压、脉搏、呼吸、体温
            if (i < twArr.length - 1 - 1) {
                var ileft = left - ((contentStartLeft - origin.x) / 2) * 0 - 28;
                $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace / 2) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + twArr[i + 1] + '℃</div>');
                $div.appendTo($board);
                //
                //               ileft = left - ((contentStartLeft - origin.x) / 4) * 1 - 28;
                //               $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace / 2) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                //+ hxArr[i + 1] + '</div>');
                //               $div.appendTo($board);
                //
                ileft = left - ((contentStartLeft - origin.x) / 2) * 1 - 28;
                $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace / 2) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + mbArr[i + 1] + '</div>');
                $div.appendTo($board);
                //
                //               ileft = left - ((contentStartLeft - origin.x) / 4) * 3 - 28;
                //               $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace / 2) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                //+ xyArr[i + 1] + '</div>');
                //               $div.appendTo($board);
            }
            //中间的4条温度的线（在这条线之上）
            for (var j = 0; j < 4; j++) {
                top = contentStartTop + sspace * 5 * i + sspace * (j + 1);
                drawLine(contentStartLeft, top, twLastLeft - contentStartLeft);
            }
        }
        //底部table画横线
        for (var i = 0; i < bottomtrCount; i++) {
            top = twLastTop + spc * (i + 1);
            var widthlength = twLastLeft - origin.x;
            if (i == bottomtrCount - 1) {
                widthlength++;  //使其看似闭合
            }
            drawLine(origin.x, top, widthlength);
        }
        //底部table  table的线和div难对其，所以用div画线
        $board.find('.bottomtbl').css('width', twLastLeft - origin.x)
            .css('left', origin.x).css('top', twLastTop).show();
        $board.find('.bottomtbl td').css('width', contentStartLeft - origin.x)
            .css('height', spc).css('line-height', spc + 'px');

        var thistdhtml = '<td style="width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;"></td>';
        for (var i = 0; i < rqCellValueArr.length; i++) {
            var thistd = "";
            var rqData = $.jsonWhere(data, function (v) { return v.rq && $.getDate({ date: v.rq }) == rqCellValueArr[i] });
            var thistz = "";
            var thisxybhd = 0;
            var thisxybhd = 0;
            var thisxyll = 0;
            var thisdbcs = 0;
            var thissrl = 0;    //摄入量(ml)
            var thisxbl = 0;
            var thisotl = 0;
            var thisyll = 0;    //引流量
            var thissrytl = 0;    //输入液体量
            var thishx = 0;//呼吸
            var thissj = 0;
            var thisgxy = 0;//高血压
            var thisdxy = 0;//低血压

            if (rqData.length < 1) {
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
            } else {
                //hss 修改于2019.08.22 呼吸显示bug修复
                for (var k = 1; k < 7; k++) {
                    var f = false;
                    var hx = "";
                    $.each(rqData, function (i, v) {
                        if (v.hx && v.sj / 4 == k) {
                            f = true;
                            hx = v.hx;
                        }
                    });
                    if (!f) {
                        thistd += thistdhtml;
                    } else {
                        thistd += '<td style="width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + hx + '</td>';
                    }
                }
            }
            for (var j = 0; j < rqData.length; j++) {

                if (rqData[j].tz) {
                    if (rqData[j].brzt == "10") {
                        thistz += "卧";
                    } else {
                        thistz += rqData[j].tz.toString();
                    }
                }
                if (rqData[j].xybhd) {
                    thisxybhd = rqData[j].xybhd;
                }
                if (rqData[j].xyll) {
                    thisxyll = rqData[j].xyll;
                }
                if (rqData[j].dbcs) {
                    thisdbcs += rqData[j].dbcs;
                }
                if (rqData[j].xbl) {
                    thisxbl += rqData[j].xbl;
                }
                if (rqData[j].otl) {
                    thisotl += rqData[j].otl;
                }
                if (rqData[j].syl) {
                    thissrl += rqData[j].syl;
                }
                if (rqData[j].ysl) {
                    thissrl += rqData[j].ysl;
                }
                if (rqData[j].sxl) {
                    thissrl += rqData[j].sxl;
                }
                if (rqData[j].cys) {
                    thisyll += rqData[j].cys;
                }
                if (rqData[j].skyll) {
                    thisyll += rqData[j].skyll;
                }
                if (rqData[j].xyl) {
                    thisyll += rqData[j].xyl;
                }
                if (rqData[j].wyl) {
                    thisyll += rqData[j].wyl;
                }
                if (rqData[j].fxxq) {
                    thisyll += rqData[j].fxxq;
                }
                if (rqData[j].qtsc) {
                    thisyll += rqData[j].qtsc;
                }
                if (rqData[j].srytl) {
                    thissrytl += rqData[j].srytl;
                }
                if (rqData[j].xysz) {
                    thisgxy = rqData[j].xysz;
                }
                if (rqData[j].xyxz) {
                    thisdxy = rqData[j].xyxz;
				}
				//住院状态
				var brzt1 = ["", "入", "在", "出", "请", "转", "转", "拒", "返", "复", "卧"];
				var brzt2 = ["", "院", "院", "院", "假", "入", "出", "测", "院", "测", "床"]
				for (var j = 0; j < rqData.length; j++) {
					if (rqData[j].brzt) {
						thisbrzt = rqData[j].brzt;
					}
					if (thisbrzt == "1" || thisbrzt == "3" || thisbrzt == "4" || thisbrzt == "8") {
						left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
						top = origin.y + spc * 4-spc;
						$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
							+ brzt1[thisbrzt] + '</div>');
						$div.appendTo($board);
					}
				}
				for (var j = 0; j < rqData.length; j++) {
					if (rqData[j].brzt) {
						thisbrzt = rqData[j].brzt;
					}
					if (thisbrzt == "1" || thisbrzt == "3" || thisbrzt == "4" || thisbrzt == "8") {
						left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
						top = origin.y + spc * 5 - spc;

						$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
							+ brzt2[thisbrzt] + '</div>');
						$div.appendTo($board);
					}
				}

				//时间显示 
				for (var j = 0; j < rqData.length; j++) {
					var showSJ = "";
					if (rqData[j].sj < 10) {
						showSJ = "0";
					} else {
						showSJ = rqData[j].sj.toString().substring(0, 1);
					}
					left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
					top = origin.y + spc * 7.4 - spc;

					$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
						+ showSJ + '</div>');
					$div.appendTo($board);
				}
				for (var j = 0; j < rqData.length; j++) {
					var showSJ = "";
					if (rqData[j].sj < 8) {
						showSJ = rqData[j].sj.toString().substring(0, 1);
					} else {
						showSJ = rqData[j].sj.toString().substring(1, 2);
					}
					left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
					top = origin.y + spc * 8.1 - spc;

					$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
						+ showSJ + '</div>');
					$div.appendTo($board);
				}
				for (var j = 0; j < rqData.length; j++) {
					var showSJ = ":";
					left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
					top = origin.y + spc * 8.7 - spc;

					$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
						+ showSJ + '</div>');
					$div.appendTo($board);
				}
				for (var j = 0; j < rqData.length; j++) {
					var showSJ = "0";
					left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
					top = origin.y + spc * 9.4 - spc;

					$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
						+ showSJ + '</div>');
					$div.appendTo($board);
				}
				for (var j = 0; j < rqData.length; j++) {
					var showSJ = "0";
					left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
					top = origin.y + spc * 10.1 - spc;

					$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
						+ showSJ + '</div>');
					$div.appendTo($board);
				}
            }
            $(thistd).appendTo($($board.find('.bottomtbl tr')[0]));

            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisgxy ? thisgxy + '/' : '') + (!!thisdxy ? thisdxy : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[1]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisxybhd ? thisxybhd : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[2]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisxyll ? thisxyll : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[3]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisdbcs ? thisdbcs : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[4]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thissrl ? thissrl : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[5]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisxbl ? thisxbl : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[6]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisotl ? thisotl : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[7]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisyll ? thisyll : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[8]));
            //输入液体量
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thissrytl ? thissrytl : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[9]));
            var $td = $('<td colspan="6" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thistz ? thistz : '') + '</td>');
            $td.appendTo($($board.find('.bottomtbl tr')[10]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + '' + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            $td.appendTo($($board.find('.bottomtbl tr')[11]));
        }

        //写日期，住院天数和时间th
        {
            var left = origin.x;
            var top = origin.y;
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top
                + 'px;width:' + (contentStartLeft - left) + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + '日期' + '</div>');
            $div.appendTo($board);
            var top = origin.y + spc;
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top
                + 'px;width:' + (contentStartLeft - left) + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + '住院天数' + '</div>');
            $div.appendTo($board);
            var left = origin.x;
            var top = top + spc;
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top
                + 'px;width:' + (contentStartLeft - left) + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + '时间' + '</div>');
            $div.appendTo($board);
        }
        //写日期和时间点
        for (var i = 0; i < rqCellValueArr.length; i++) {
            var left = contentStartLeft + i * sspacewidth * 6;
            var top = origin.y;
            var thisrq = rqCellValueArr[i];
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + $.getDate({ date: thisrq }) + '</div>');
            $div.appendTo($board);
            top = origin.y + spc;
            var zyts = parseInt(Math.abs(Math.abs(new Date(ryrq) - new Date(thisrq))) / 1000 / 60 / 60 / 24) + 1;
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + zyts + '</div>');
            $div.appendTo($board);
            for (var j = 0; j < 6; j++) {
                left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
                top = origin.y + spc * 2;

                $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + 4 * (j + 1) + '</div>');
                $div.appendTo($board);
            }
        }

        //左侧血压、脉搏、呼吸、体温 竖线+文字
        for (var i = 0; i < 2; i++) {
            var left = origin.x + ((contentStartLeft - origin.x) / 2) * i;
            var top = contentStartTop;
            drawLine(left, top, twLastTop - contentStartTop, '', 'vline');
            //文字
            var $div;
            //            if (i == 0) {
            //                $div = $('<div style="position:absolute;text-align:center;left:' + origin.x + 'px;top:' + top + 'px;width:' + ((contentStartLeft - origin.x) / 4) + 'px;height:' + spc * 3 + 'px;line-height:' + spc + 'px;">'
            //+ '血压<br/>mmHg' + '</div>');
            //                $div.appendTo($board);
            //                drawUparrow(left - sspacewidth * 1.2, top + sspace * 3, xyszColor);
            //                drawDownarrow(left - sspacewidth * 1.2, top + sspace * (4.5), xyxzColor);
            //            }
            $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + ((contentStartLeft - origin.x) / 2) + 'px;height:' + spc * 1 + 'px;line-height:' + spc + 'px;">'
                + (i == 0 ? '脉搏(次/分)' : (i == 1 ? '体温<br/>(℃)' : '')) + '</div>');
            i == 0 ? drawDot(left + sspacewidth * 1.2, top + sspace * 3, mbColor)
                : (i == 1 ? drawX(left + sspacewidth * 1.8, top + sspace * 3, twColor)
                    : '');
            $div.appendTo($board);
        }
    }

    //画点
    function drawDataPoint(data) {
        //画点
        for (var i = 0; i < data.length; i++) {
            if (data[i].rq && data[i].sj && data[i].sj % 4 == 2) {
                drawTwPoint(data[i]);
                drawMbPoint(data[i]);
                drawWljwPoint(data[i]);
                //drawHxPoint(data[i]);
                //drawXyPoint(data[i]);
            }
        }
    }

    //画连线
    function drawDataLigature(data) {
        //画连线
        var tempArr;
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.twLocation })).length - 1; i++) {
            if (tempArr[i].twLocation && tempArr[i + 1].twLocation) {
                if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
					if (tempArr[i].brzt != 4) {
						drawLigature(tempArr[i].twLocation, tempArr[i + 1].twLocation, 'cblue');
					}
                }
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.hxLocation })).length - 1; i++) {
            if (tempArr[i].hxLocation && tempArr[i + 1].hxLocation) {
                if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    drawLigature(tempArr[i].hxLocation, tempArr[i + 1].hxLocation, hxColor);
                }
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.mbLocation })).length - 1; i++) {
            if (tempArr[i].mbLocation && tempArr[i + 1].mbLocation) {
                if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    drawLigature(tempArr[i].mbLocation, tempArr[i + 1].mbLocation, mbColor);
                }
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.xyszLocation })).length - 1; i++) {
            if (tempArr[i].xyszLocation && tempArr[i + 1].xyszLocation) {
                if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    drawLigature(tempArr[i].xyszLocation, tempArr[i + 1].xyszLocation, xyszColor);
                }
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.xyxzLocation })).length - 1; i++) {
            if (tempArr[i].xyxzLocation && tempArr[i + 1].xyxzLocation) {
                if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    drawLigature(tempArr[i].xyxzLocation, tempArr[i + 1].xyxzLocation, xyxzColor);
                }
            }
        }
        //物理降温和体温连线
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.twLocation })).length; i++) {
            if (tempArr[i].twLocation && tempArr[i].wljwLocation) {
                drawLigature(tempArr[i].twLocation, tempArr[i].wljwLocation, twColor, 'dotline');//虚线连接
            }
        }
		//住院状态和时间 虚线连接
		for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.twLocation })).length; i++) {
			if (tempArr[i].brzt == "1" || tempArr[i].brzt == "3" || tempArr[i].brzt == "4" || tempArr[i].brzt == "8") {
				var brztLocation = { x: tempArr[i].twLocation.x, y: origin.y + spc * 6 -spc};
				var sjLocation = { x: tempArr[i].twLocation.x, y: origin.y + spc * 7.2 -spc};
				drawLigature(brztLocation, sjLocation, twColor, 'dotline');//虚线连接
			}
		}
    }

    //画体温点
    function drawTwPoint(item) {
        if (item.tw) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
			var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * ((item.sj + 2)/ 4 - 1);
            var top = contentStartTop;
            if (item.tw > twArr[0]) {
                top = contentStartTop;
            }
            else if (item.tw < twArr[twArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每1度占5格 .toFixed(2)是js减法bug
                top += (twArr[0] - item.tw).toFixed(2) * 5 * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(twArr, function (v) { return v == item.tw }).length == 1
                && item.tw != twArr[0] && item.tw != twArr[twArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.twLocation = { x: left, y: top };
            drawX(left, top, twColor, item.tw);
            //伪造title
            drawFalsifyTitle(left, top, item.tw);
        }
    }

    //画脉搏点
    function drawMbPoint(item) {
        if (item.mb) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
			var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * ((item.sj + 2) / 4 - 1);
            var top = contentStartTop;
            if (item.mb > mbArr[0]) {
                top = contentStartTop;
            }
            else if (item.mb < mbArr[mbArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每20占5格 即每4占一格 .toFixed(2)是js减法bug
                top += ((mbArr[0] - item.mb).toFixed(2) / 4).toFixed(2) * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(mbArr, function (v) { return v == item.mb }).length == 1
                && item.mb != mbArr[0] && item.mb != mbArr[mbArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.mbLocation = { x: left, y: top };
            drawDot(left, top, mbColor, item.mb);
            //伪造title
            drawFalsifyTitle(left, top, item.mb);
        }
    }

    //画呼吸点
    function drawHxPoint(item) {
        if (item.hx) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
			var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * ((item.sj + 2) / 4 - 1);
            var top = contentStartTop + sspacewidth * 32;
            //if (item.hx > hxArr[0]) {
            //    top = contentStartTop;
            //}
            //else if (item.hx < hxArr[hxArr.length - 1]) {
            //    top = twLastTop;
            //}
            //else {
            //    //*5是因为每10占5格 即每2占一格 .toFixed(2)是js减法bug
            //    top += ((hxArr[0] - item.hx).toFixed(2) / 2).toFixed(2) * sspace;
            //}
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(hxArr, function (v) { return v == item.hx }).length == 1
                && item.hx != hxArr[0] && item.hx != hxArr[hxArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.hxLocation = { x: left, y: top };
            drawSquare(left, top, hxColor, item.hx);
            //伪造title
            drawFalsifyTitle(left, top, item.hx);
        }
    }

    //画血压点
    function drawXyPoint(item) {
        var idx = getIndexOfRq(item.rq);
        if (idx < 0) {
            return;
        }
        if (item.xysz) {
			var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * ((item.sj + 2) / 4 - 1);
            var top = contentStartTop;
            if (item.xysz > xyArr[0]) {
                top = contentStartTop;
            }
            else if (item.xysz < xyArr[xyArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每20占5格 即每4占一格 .toFixed(2)是js减法bug
                top += ((xyArr[0] - item.xysz).toFixed(2) / 4).toFixed(2) * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(xyArr, function (v) { return v == item.xysz }).length == 1
                && item.xysz != xyArr[0] && item.xysz != xyArr[xyArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.xyszLocation = { x: left, y: top };
            drawUparrow(left, top, xyszColor, item.xysz);
            //伪造title
            drawFalsifyTitle(left, top, item.xysz);
        }
        if (item.xyxz) {
			var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * ((item.sj + 2) / 4 - 1);
            var top = contentStartTop;
            if (item.xyxz > xyArr[0]) {
                top = contentStartTop;
            }
            else if (item.xyxz < xyArr[xyArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每20占5格 即每4占一格 .toFixed(2)是js减法bug
                top += ((xyArr[0] - item.xyxz).toFixed(2) / 4).toFixed(2) * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(xyArr, function (v) { return v == item.xyxz }).length == 1
                && item.xyxz != xyArr[0] && item.xyxz != xyArr[xyArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.xyxzLocation = { x: left, y: top };
            drawDownarrow(left, top, xyxzColor, item.xyxz);
            //伪造title
            drawFalsifyTitle(left, top, item.xyxz);
        }
    }

    //画物理降温
    function drawWljwPoint(item) {
        if (item.wljw) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
			var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * ((item.sj + 2) / 4 - 1);
            var top = contentStartTop;
            if (item.wljw > wljwArr[0]) {
                top = contentStartTop;
            }
            else if (item.wljw < wljwArr[wljwArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每1度占5格 .toFixed(2)是js减法bug
                top += (wljwArr[0] - item.wljw).toFixed(2) * 5 * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(wljwArr, function (v) { return v == item.wljw }).length == 1
                && item.wljw != wljwArr[0] && item.wljw != wljwArr[wljwArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.wljwLocation = { x: left, y: top };
            drawRound(left, top, wljwColor, item.wljw);
            //伪造title
            drawFalsifyTitle(left, top, item.wljw);
        }
    }

    //type默认横线，传递false画竖线
    function drawLine(left, top, length, colorClass, type, bold, zIndex) {
        var html = '<div style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
        html += (type === 'vline' ? 'height' : 'width') + ":" + length + "px;";
        if (zIndex) {
            html += 'z-index:' + zIndex + ';';
        }
        html += '"';
        html += ' class="';
        //默认横线
        var lineClass = (type === 'vline' ? 'vline' : 'line');
        lineClass = bold === 'bold' ? lineClass + "bold" : lineClass;
        html += ' ' + lineClass;
        //颜色默认#999
        html += ' ' + (!!colorClass ? colorClass : 'c999');
        html += '"';
        html += '>';
        html += '</div>';
        var $html = $(html);
        $html.appendTo($board);
        return $html;
    }

    //以(left, top)为中心画一个点
    function drawDot(left, top, colorClass) {
        //考虑border呈现问题
        left = left - 3;    //3为border的宽度
        top = top - 3;
        var html = '<div style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
        html += '"';
        html += ' class="dot';
        //颜色默认#999
        html += ' ' + (!!colorClass ? colorClass : 'c999');
        html += '"';
        html += '>';
        html += '</div>';
        var $html = $(html);
        $html.appendTo($board);
        return $html;
    }

    //以(left, top)为中心画一个X
    function drawX(left, top, colorClass) {
        if (canvasdrawX(left, top, colorClass)) {
            return;
        }
        //left - 1是因为length 2
        drawLine(left - 0.5 - 1, top - 0.5, 2, colorClass);
        drawLine(left - 1.5 - 1, top - 1.5, 2, colorClass);
        drawLine(left - 2.5 - 1, top - 2.5, 2, colorClass);
        drawLine(left + 0.5 - 1, top + 0.5, 2, colorClass);
        drawLine(left + 1.5 - 1, top + 1.5, 2, colorClass);
        drawLine(left + 2.5 - 1, top + 2.5, 2, colorClass);
        //
        drawLine(left + 0.5 - 1, top - 0.5, 2, colorClass);
        drawLine(left + 1.5 - 1, top - 1.5, 2, colorClass);
        drawLine(left + 2.5 - 1, top - 2.5, 2, colorClass);
        drawLine(left - 0.5 - 1, top + 0.5, 2, colorClass);
        drawLine(left - 1.5 - 1, top + 1.5, 2, colorClass);
        drawLine(left - 2.5 - 1, top + 2.5, 2, colorClass);
    }

    //以(left, top)为中心画一个Square
    function drawSquare(left, top, colorClass) {
        if (canvasdrawSquare(left, top, colorClass)) {
            return;
        }
        drawLine(left - 2.5, top - 2.5, 6, colorClass);
        drawLine(left - 2.5, top + 2.5, 6, colorClass);
        drawLine(left - 2.5, top - 2.5, 6, colorClass, 'vline');
        drawLine(left + 2.5, top - 2.5, 6, colorClass, 'vline');
    }

    //以(left, top)为中心画一个上箭头
    function drawUparrow(left, top, colorClass) {
        if (canvasdrawUparrow(left, top, colorClass)) {
            return;
        }
        top += 2;   //使箭头在线上
        //left - 1是因为length 2
        drawLine(left - 1, top - 2, 2, colorClass);
        //
        drawLine(left + 1 - 1, top - 1, 2, colorClass);
        drawLine(left + 2 - 1, top, 2, colorClass);
        drawLine(left + 3 - 1, top + 1, 2, colorClass);
        drawLine(left + 4 - 1, top + 2, 2, colorClass);
        //
        drawLine(left - 1 - 1, top - 1, 2, colorClass);
        drawLine(left - 2 - 1, top, 2, colorClass);
        drawLine(left - 3 - 1, top + 1, 2, colorClass);
        drawLine(left - 4 - 1, top + 2, 2, colorClass);
    }

    //以(left, top)为中心画一个下箭头
    function drawDownarrow(left, top, colorClass) {
        if (canvasdrawDownarrow(left, top, colorClass)) {
            return;
        }
        top -= 2;   //使箭头在线上
        //left - 1是因为length 2
        drawLine(left - 1, top + 2, 2, colorClass);
        //
        drawLine(left + 1 - 1, top + 1, 2, colorClass);
        drawLine(left + 2 - 1, top, 2, colorClass);
        drawLine(left + 3 - 1, top - 1, 2, colorClass);
        drawLine(left + 4 - 1, top - 2, 2, colorClass);
        //
        drawLine(left - 1 - 1, top + 1, 2, colorClass);
        drawLine(left - 2 - 1, top, 2, colorClass);
        drawLine(left - 3 - 1, top - 1, 2, colorClass);
        drawLine(left - 4 - 1, top - 2, 2, colorClass);
    }

    //以(left, top)为中心画一个空心圆
    function drawRound(left, top, colorClass) {
        //考虑border呈现问题
        left = left - 3;    //3为border的宽度
        top = top - 3;
        var html = '<div style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
        html += '"';
        html += ' class="round';
        //颜色默认#999
        html += ' ' + (!!colorClass ? colorClass : 'c999');
        html += '"';
        html += '>';
        html += '</div>';
        var $html = $(html);
        $html.appendTo($board);
        return $html;
    }


    //两点画连线 p2.x 比 p1.x大
    function drawLigature(p1, p2, colorClass, type) {//2021-2-5 增加type参数 dotline为虚线
        if (canvasdrawLigature(p1, p2, colorClass, type)) {
            return;
        }
        //x x之间多少个像素
        var xDifference = parseInt(p2.x - p1.x);
        //要画xDifference个像素点
        for (var i = 0; i < xDifference; i++) {
            var left = p1.x + i;
            var dwspace = ((p2.y - p1.y) / xDifference);
            var pointCount = dwspace % 1 == 0 ? Math.abs(parseInt(dwspace)) : (Math.abs(parseInt(dwspace)) + 1);
            if (pointCount == 0) {
                //这是横线
                var top = p1.y;
                if (type == 'dotline') {//虚线
                    drawLine(left, top, 1, colorClass, 'dotline', '', 2);
                } else {
                    drawLine(left, top, 1, colorClass, '', '', 2);
                }
            }
            else if (pointCount == 1) {
                var top = p1.y + dwspace * i;
                if (type == 'dotline') {//虚线
                    drawLine(left, top, 1, colorClass, 'dotline', '', 2);
                } else {
                    drawLine(left, top, 1, colorClass, '', '', 2);
                }
            }
            else {
                //pointCount点的数量
                for (var j = 0; j < pointCount; j++) {
                    left = left + (1.0 / pointCount);//已经累加了
                    var top = p1.y + dwspace * i + ((dwspace / pointCount) * j);
                    drawLine(left, top, 1, colorClass, '', '', 2);
                }
            }
        }
    }

    //伪造title
    function drawFalsifyTitle(left, top, title) {
        if (!!title) {
            var html = '<div style="position:absolute;width:14px;height:14px;z-index:1;left:' + (left - 7) + 'px;top:' + (top - 7) + 'px;';
            html += '"';
            html += ' title="' + title + '"';
            html += '>';
            html += '</div>';
            $(html).appendTo($board);
        }
    }

    function fillPatBaseInfo(patInfo) {
        $('#lblXm').html(patInfo.xm);
        $('#lblBlh').html(patInfo.blh);
        $('#lblZyh').html(patInfo.zyh);
        $('#lblBq').html(patInfo.bqmc);
        $('#lblCw').html(patInfo.cwmc);
        //$('#lblRyrq').html(patInfo.ryrq.substring(0,10));
        if (patInfo.ryrq != null) {
            $('#lblRqrq').html(patInfo.ryrq.substring(0, 10));
        }

        if (patInfo.cqrq != null) {
            $('#lblCqrq').html(patInfo.cqrq.substring(0, 10));
        }
    }

</script>
<script>
    //全局变量
    var canvasAble = false;
    //只调用一次即可
    function checkCanvasAble() {
        try {
            var myCanvas = document.getElementById("drawCanvas" + billIndex);
            if (myCanvas == null) {
                return;
            }
            var context = myCanvas.getContext("2d");
            canvasAble = true;
        }
        catch (eeerree) {
        }
    }

    //canvas两点画连线 p2.x 比 p1.x大
    function canvasdrawLigature(p1, p2, colorClass, type) {//增加type参数,为dotline时画虚线
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        if (type == 'dotline') {//画虚线
            context.setLineDash([2, 3]);
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 1;//设置线宽
        context.beginPath();
        context.moveTo(p1.x, p1.y);
        context.lineTo(p2.x, p2.y);
        context.stroke();//画线框
        return true;
    }

    //canvas以(left, top)为中心画一个下箭头
    function canvasdrawDownarrow(left, top, colorClass) {
        top -= 2;   //使箭头在线上
        //left - 1是因为length 2
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left + 4 + 1, top - 2 - 1);
        context.lineTo(left, top + 2);
        context.lineTo(left - 4 - 1, top - 2 - 1);
        context.stroke();//画线框

        return true;
    }

    //canvas以(left, top)为中心画一个上箭头
    function canvasdrawUparrow(left, top, colorClass) {
        top += 2;   //使箭头在线上
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left + 4 + 1, top + 2 + 1);
        context.lineTo(left, top - 2);
        context.lineTo(left - 4 - 1, top + 2 + 1);
        context.stroke();//画线框

        return true;
    }

    //canvas以(left, top)为中心画一个X
    function canvasdrawX(left, top, colorClass) {
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left - 3, top + 3);
        context.lineTo(left + 3, top - 3);
        context.moveTo(left + 3, top + 3);
        context.lineTo(left - 3, top - 3);
        context.stroke();//画线框

        return true;
    }

    //canvas以(left, top)为中心画一个Square
    function canvasdrawSquare(left, top, colorClass) {
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left - 3, top - 3);
        context.lineTo(left + 3, top - 3);
        context.lineTo(left + 3, top + 3);
        context.lineTo(left - 3, top + 3);
        //context.lineTo(left - 3, top - 3);
        context.closePath();
        context.stroke();//画线框

        return true;
    }

    //获取rq在rqCellValueArr中index
    function getIndexOfRq(rq) {
        rq = $.getDate({ date: rq, ute: true });
        for (var iiIndex = 0; iiIndex < rqCellValueArr.length; iiIndex++) {
            if (rq == rqCellValueArr[iiIndex]) {
                return iiIndex;
            }
        }
        return -1;
    }

</script>
